<?php
/*
* Copyright (c) 2017 Baidu.com, Inc. All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* Http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
declare (strict_types = 1);

namespace learn\baidu;

use learn\baidu\AipOcr;

class BaiduShow
{
    //配置
    public static function options()
    {
        

        $config = systemConfigMore(['baidu_appid','baidu_apikey',"baidu_secretkey"]);
        $client  = new AipOcr($config['baidu_appid'
    ], $config['baidu_apikey'], $config['baidu_secretkey']);
        return $client;
    } 


    /**
     * 身份证识别
     * url   图片链接
     * type   front --- 身份证含照片的一面          front：身份证含照片的一面；back：身份证带国徽的一面
     * options 其他类型
     */
    public static function idcard($url,$type,$options = [])
    {
        $client = self::options();
        //获取图片
        $image = file_get_contents($url);
        // 调用身份证识别
        $data = $client->idcard($image, $type,$options);
        return $data;
    }

    /**
     * 银行卡识别
     * url   图片链接
     */
    public static function bankcard($url)
    {
        $client = self::options();
        //获取图片
        $image = file_get_contents($url);
        // 调用身份证识别
        $data = $client->bankcard($image);
        return $data;
    }

    
    /**
     * 行驶证识别
     * url   图片链接
     * options 其他配置 
     * options['vehicle_license_side']  front：识别行驶证主页     back：识别行驶证副页
     */
    public static function vehiclecard($url,$options = [])
    {
        $client = self::options();
        //获取图片
        $image = file_get_contents($url);
        // 调用身份证识别
        $data = $client->vehicleLicense($image,$options);
        return $data;
    }

    /**
     * 通用文字识别
     * url   图片链接
     * options 其他配置 
     */
    public static function basicGeneral($url,$options = [])
    {
        $client = self::options();
        //获取图片
        $image = file_get_contents($url);
        // 调用身份证识别
        $data = $client->basicGeneral($image,$options);
        return $data;
    }

    /**
     * 添加用户到人脸库
     */

}
